package com.ym.wcp.framework.mybatis;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;

/**
 * 分页参数
 *
 * @author hospital
 * @date 2020年02月14日16:19:36
 */
@Data
@ApiModel(value = "PageParams", description = "分页参数")
public class PageParams<T> {

    @Valid
    @ApiModelProperty(value = "查询参数", required = true)
    private T model;

    @ApiModelProperty(value = "页面大小", example = "10")
    private int size = 10;

    @ApiModelProperty(value = "当前页", example = "1")
    private int current = 1;

    @JsonIgnore
    public IPage<T> buildPage() {
        return new Page<>(getCurrent(), getSize());
    }

    @JsonIgnore
    public <E> IPage<E> buildPage(Class<E> cls) {
        return new Page<>(getCurrent(), getSize());
    }
}
